package com.wang.pages.usermgm;

import java.util.List;

import javax.inject.Inject;

import org.apache.tapestry5.annotations.PageActivationContext;
import org.apache.tapestry5.annotations.Property;

import com.wang.entities.User;
import com.wang.services.StateDAO;

public class UserList {
	//打开user读写
	@Property
	private User user;
	 
	//打开user阵列的读写
	@Property
	private List<User> users;
	 
	//导入操作数据库的服务
	@Inject
	private StateDAO dao;
	 
	//当前页面接收user的id值
	@PageActivationContext
	private Long id;
	 
	//页面加载时设置渲染
	void setupRender(){
	//查询User数据表
	StringBuffer sql = new StringBuffer();
	sql.append("from User");
	users = dao.findWithQuery(sql.toString());
	}
	 
	//单击eventlink执行删除操作
	Object onDelete(Long id){
	dao.deleteByID(User.class, id);
	return this;
	}
}
